package com.lap.framework.junit.shared.tool;

import java.util.Optional;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.ClassUtils;

@UtilityClass
public class TypeUtil {

  public static boolean isPrimitiveOrWrapperOrString(Class<?> clazz) {
    return ClassUtils.isPrimitiveOrWrapper(clazz) || clazz == String.class;
  }

  public static boolean isPageRequestType(Class<?> clazz) {
    return clazz != null
        && Optional.ofNullable(clazz.getSuperclass())
            .map(Class::getSimpleName)
            .filter("PageRequest"::equalsIgnoreCase)
            .isPresent();
  }
}
